import math
import os
import sys

def count_size(size, block_size):
    total = int(math.ceil(float(size)/float(block_size)))
    print(total* block_size)
    return total* block_size


def count_dir(dr, block_size):
    total = 0
    for j in os.listdir(dr):
        i = dr +'\\' +j
        if os.path.isdir(i):
            size= count_dir(i, block_size)
            total += size
        if os.path.isfile(i) and (j.endswith('.gif') or j.endswith('.jpg')or j.endswith('.txt')):
            print(i)
            size = count_size(os.path.getsize(i), block_size)
            total += int(size)
    return total
                                


if __name__=="__main__":
    dr = os.getcwd()
    block_size=4096
    if len(sys.argv)== 2:
        dr = sys.argv[1]
    elif len(sys.argv) >2:
        dr = sys.argv[1]
        block_size=int(sys.argv[2])
    print(dr)
    t = count_dir(dr, block_size)
    print(t)
